package com.smyh.bean.Enum;

import java.util.ArrayList;
import java.util.List;
import java.util.Vector;

/**
 * 遥信点位类型
 */
public enum PointDigitType {

	A_DF(1,"A相短路"),B_DF(2,"B相短路"),C_DF(3,"C相短路"),MERGE_DF(4,"短路合并(测量点1短路)"),
	A_8F(5,"A相接地"),B_8F(6,"B相接地"),C_8F(7,"C相接地"),MERGE_8F(8,"接地合并(测量点1接地)"),
	A_CF(9,"A相通讯"),B_CF(10,"B相通讯"),C_CF(11,"C相通讯"),MERGE_CF(12,"通讯合并(测量点1通讯)"),
	A_OF(13,"A相过流"),B_OF(14,"B相过流"),C_OF(15,"C相过流"),O_OF(16,"0序过流"),MERGE_OF(17,"过流合并(测量点1过流)"),
	A_FAST_CUT(18,"A相速断"),B_FAST_CUT(19,"B相速断"),C_FAST_CUT(20,"C相速断"),MERGE_FAST_CUT(21,"速断合并(测量点1速断)"),
	A_STOP_ELEC(22,"A相断电"),B_STOP_ELEC(23,"B相断电"),C_STOP_ELEC(24,"C相断电"),MERGE_STOP_ELEC(25,"断电合并(测量点1断电)"),
	A_BVF(26,"A相电池欠压"),B_BVF(27,"B相电池欠压"),C_BVF(28,"C相电池欠压"),MERGE_BVF(29,"欠压合并(测量点1电池欠压)"),
	A_UP_ELE(30,"A相上电"),	B_UP_ELE(31,"B相上电"),	C_UP_ELE(32,"C相上电"),	MERGE_UP_ELE(33,"上电合并(测量点1上电)"),
	A_HEART(34,"A相心跳"),	B_HEART(35,"B相心跳"),	C_HEART(36,"C相心跳"),	MERGE_HEART(37,"心跳合并(测量点1心跳)"),
	A_BY_1(38,"A相备用-1"),	B_BY_1(39,"B相备用-1"),	C_BY_1(40,"C相备用-1"),	
	A_BY_2(41,"A相备用-2"),B_BY_2(42,"B相备用-2"),C_BY_2(43,"C相备用-2"),FILL(50,"填充位"),
	A(100,"电池欠压"),B(101,"后备电源切换"),C(102,"装置异常告警"),D(103,"备用1"),E(104,"备用2"),F(105,"备用3"),G(106,"备用4");
	
	private String name;
	private int index;
	/**
	 * 构造方法
	 * @param index
	 * @param desc
	 */
	PointDigitType(int index,String desc){
		this.setIndex(index);
		this.setName(desc);
	}
	/**
	 * 普通方法
	 */
    public static String getName(Integer index) {
    	if( index == null || index==0 ){
    		return "";
    	}
        for (PointDigitType pointDigitType : PointDigitType.values()) {  
            if (pointDigitType.getIndex() == index) {  
                return pointDigitType.name;  
            }  
        }  
        return "";  
    }
    public static Integer getIndex(String name) {
		if("".equals(name)||name == null){
			return null;
		}
        for (PointDigitType pointDigitType : PointDigitType.values()) {  
            if (pointDigitType.getName().equals(name)) {  
                return pointDigitType.index;  
            }  
        }  
        return null;  
    }
    public static List<String> getFiltNames(){
		List<String> list = new ArrayList<String>();
		for (PointDigitType pointDigitType : PointDigitType.values()) {
			if(pointDigitType.getName().contains("A相")){
				if(!pointDigitType.getName().contains("备用"))
					list.add(pointDigitType.getName().substring(2));
			}
		}
		return list;
	}
    public static List<Integer> containsNameCount(String name){
		 List<Integer> list = new ArrayList<Integer>();
		 //占位
		 list.add(0);
		 list.add(0);
		 list.add(0);
		 list.add(0);
		 list.add(0);
		for (PointDigitType pointDigitType : PointDigitType.values()) {
			if(pointDigitType.getName().contains(name)){
				if(pointDigitType.getName().contains("A相")){
					list.set(0, pointDigitType.getIndex());
				}else if(pointDigitType.getName().contains("B相")){
					list.set(1, pointDigitType.getIndex());
				}else if(pointDigitType.getName().contains("C相")){
					list.set(2, pointDigitType.getIndex());
				}else if(pointDigitType.getName().contains("0序")){
					list.set(3, pointDigitType.getIndex());
				}else if(pointDigitType.getName().contains("合并")){
					list.set(4, pointDigitType.getIndex());
				}
			}
		}
		return list;
	}
    
    private static Vector vectors = null;
    /**
     * 返回所有的index
     * @return
     */
    public static Vector<Object> getNames(){
    	if(vectors==null){
    		vectors = new Vector<Object>();
    		vectors.add("");
    		for (PointDigitType pointDigitType : PointDigitType.values()) {
    			vectors.add(pointDigitType.name);
    		}
    	}
    	return vectors;
    }
	public void setIndex(int index) {
		this.index = index;
	}
	public int getIndex() {
		return index;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getName() {
		return name;
	}
	
	public static void main(String[] args) {
		for (Object string : getNames()) {
			System.out.println(string);
		}
	}
}
